<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:richext="http://java.sun.com/jsf/composite/richext">

<body>
    <ui:composition template="../templates/template.xhtml">
        <ui:define name="titre">Gestion des tarifs</ui:define>
    <ui:define name="zone1">
    	<div class="form">
    		<h:form>
    			<h:messages id="messages" warnClass="msgWarn" errorClass="msgError" infoClass="msgInfo"
							globalOnly="true" styleClass="borderBleu messageBloc"/>
				<div  class="borderBleu">
					<h:panelGroup rendered="#{fn:length(ParametrageControleur.modele.classes) > 0}"  >
						<div class="titre">
							<h:outputLabel value="Liste des tarifs" />
						</div>
					</h:panelGroup>
					<div id="formResult">
						<rich:dataTable id="tarifs" value="#{ParametrageControleur.modele.tarifs}"	
		       	 			var="tarif" rendered="#{fn:length(ParametrageControleur.modele.tarifs) > 0}" rows="10">
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Classe" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.classe}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Date début d'application" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.datedeubt}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Date fin d'application" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.datefin}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Frais d'inscription" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.inscription}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Mensualité" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.mensualite}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Frais transport" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.transport}" />
				        	</rich:column>
				        	<rich:column >
				        		<f:facet name="header">
				        			<h:outputText 	value="Etat" />
				        		</f:facet>
				        		<h:outputText value="#{tarif.etat}" />
				        	</rich:column>
				        	<rich:column>
				        		<f:facet name="header">
				        			<h:outputText 	value="" />
				        		</f:facet>
				        		<a4j:commandLink styleClass="btnTableau" value="Modifier" execute="@this" render="panelmodification" rendered="#{tarif.etat == 'CREE'}" 
				        			oncomplete="#{rich:component('panelmodification')}.show();">
				        			<f:setPropertyActionListener target="#{ParametrageControleur.modele.tarif}" value="#{tarif}" />
				        		</a4j:commandLink>
				        		<richext:spacer width="3"  rendered="#{tarif.etat =='CREE' }"/>
				        		<a4j:commandLink styleClass="btnTableau" value="Valider" execute="@this" render="popupconfirmationvalidation"  rendered="#{tarif.etat =='CREE' }"
				        			oncomplete="#{rich:component('popupconfirmationvalidation')}.show();">
				        			<f:setPropertyActionListener target="#{ParametrageControleur.modele.tarif}" value="#{tarif}" />
				        		</a4j:commandLink>
				        		<richext:spacer width="3" rendered="#{tarif.etat == 'VALIDE'}" />
				        		<a4j:commandLink styleClass="btnTableau" value="Clôturer" execute="@this" render="popupconfirmationcloture"  rendered="#{tarif.etat == 'VALIDE'}"
				        			oncomplete="#{rich:component('popupconfirmationcloture')}.show();">
				        			<f:setPropertyActionListener target="#{ParametrageControleur.modele.tarif}" value="#{tarif}" />
				        		</a4j:commandLink>
				        	</rich:column>
		        		</rich:dataTable>
					</div>
					<div id="boutons">         
	                     <a4j:commandLink styleClass="btValider" value="Ajouter un tarif" execute="@this"  
							oncomplete="#{rich:component('panelajout')}.show();">
							
	                     </a4j:commandLink>
                    </div>
	                    <!-- popup ajout tarif -->
	                    <rich:popupPanel modal="true" id="panelajout" domElementAttachment="parent" resizeable="true" width="600" height="250">
			     			<div  class="borderBleu">
						 		<div class="titre">
									<h:outputLabel value="Ajout tarif" />
								</div>
					 		</div>
			     			<h:panelGrid columns="2" columnClasses="tabline1, tabline2" styleClass="spanelTable">
			     				<h:panelGroup>
			     					<h:outputLabel value="Classe" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:selectOneMenu id="classeajout"  value="#{ParametrageControleur.modele.tarif.classe}" required="true" >
							        	<f:selectItem  itemLabel="--Selectionner--" itemValue="" />
							        	<f:selectItems  value="#{ParametrageControleur.modele.classesItems}"/>
					    			</h:selectOneMenu>
					    			<h:message id="classeajoutmsg" for="classeajout" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Date début d'application" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<rich:calendar id="datedebutajout" title="Date début application" 
											value="#{ParametrageControleur.modele.tarif.datedeubt}"
											locale="FR" datePattern="dd/MM/yyyy" enableManualInput="true"
											showApplyButton="false"  inputSize="10" 
											required="true" />
					    			<h:message id="datedebuajouttmsg" for="datedebutajout" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Frais d'inscription" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="inscriptionajout" value="#{ParametrageControleur.modele.tarif.inscription}" 
	                             	required="true" />
					    			<h:message id="inscriptionajoutmsg" for="inscriptionajout" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Mensualité" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="mensualiteajout" value="#{ParametrageControleur.modele.tarif.mensualite}" 
	                             	required="true" />
					    			<h:message id="mensualiteajoutmsg" for="mensualiteajout" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Frais transport" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="transportajout" value="#{ParametrageControleur.modele.tarif.transport}" 
	                             	required="true" />
					    			<h:message id="transportajoutmsg" for="transportajout" errorClass="msgError"/>
			     				</h:panelGroup>
			     			</h:panelGrid>
		                    <div id="boutons">         
		                     	<a4j:commandLink styleClass="btValider" value="Valider" render ="tarifs" execute="panelajout" action="#{ParametrageControleur.ajouterTarif}"
									oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('panelajout')}.hide();}">
		                     	</a4j:commandLink>
		                     	<a4j:commandLink styleClass="btAnnuler"  value="Annuler" onclick="#{rich:component('panelajout')}.hide(); return false;" />
		                    </div>    
	               		</rich:popupPanel>  
						<!-- fin popup ajout tarif -->
						<!-- popup maj tarif -->
						<rich:popupPanel modal="true"  id="panelmodification" domElementAttachment="parent" 	width="500" height="200">
	                    	<div  class="borderBleu">
						 		<div class="titre">
									<h:outputLabel value="Mise à jour du tarif" />
								</div>
					 		</div>
	                    	<h:panelGrid columns="2" columnClasses="tabline1, tabline2" styleClass="spanelTable">
	                    		<h:panelGroup>
			     					<h:outputLabel value="Classe" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:selectOneMenu id="classe"  value="#{ParametrageControleur.modele.tarif.classe}" required="true" >
							        	<f:selectItem  itemLabel="--Selectionner--" itemValue="" />
							        	<f:selectItems  value="#{ParametrageControleur.modele.classesItems}"/>
					    			</h:selectOneMenu>
					    			<h:message id="classemsg" for="classe" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Date début d'application" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<rich:calendar id="datedebut" title="Date début application" 
											value="#{ParametrageControleur.modele.tarif.datedeubt}"
											locale="FR" datePattern="dd/MM/yyyy" enableManualInput="true"
											showApplyButton="false"  inputSize="10" 
											required="true" />
					    			<h:message id="datedebutmsg" for="datedebut" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Frais d'inscription" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="inscription" value="#{ParametrageControleur.modele.tarif.inscription}" 
	                             	required="true"/>
					    			<h:message id="inscriptionmsg" for="inscription" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Mensualité" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="mensualite" value="#{ParametrageControleur.modele.tarif.mensualite}" 
	                             	required="true" />
					    			<h:message id="mensualitemsg" for="mensualite" errorClass="msgError"/>
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:outputLabel value="Frais transport" />
			     				</h:panelGroup>
			     				<h:panelGroup>
			     					<h:inputText id="transport" value="#{ParametrageControleur.modele.tarif.transport}" 
	                             	required="true" />
					    			<h:message id="transportmsg" for="transport" errorClass="msgError"/>
			     				</h:panelGroup>
	                    	</h:panelGrid>
	                    	
		                    <div id="boutons">         
			                     <a4j:commandLink styleClass="btValider" value="Valider" render ="tarifs" execute="panelmodification" action="#{ParametrageControleur.modifierTarif}"
									oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('panelmodification')}.hide();}">
			                     </a4j:commandLink>
			                     <a4j:commandLink styleClass="btAnnuler"   value="Annuler" onclick="#{rich:component('panelmodification')}.hide(); return false;" />
		                    </div>    
	               	</rich:popupPanel>
	               	<!-- fin popup maj tarif -->
	               	<!-- popoup confirmation -->
	               	<rich:popupPanel id="popupconfirmationcloture" modal="true" resizeable="true" >
	               		<div  class="borderBleu">
						 		<div class="titre">
									<h:outputLabel value="Mise à jour du tarif" />
								</div>
								<div>
									 <p>
								       	Un tarif clôturé ne pourra plus être utilisé pour les nouvelles inscriptions. Un nouveau tarif doit être crée.<br/>
								       	Voulez-vous confirmer la clôture ?
							       	</p>
								</div>
					 	</div>
			        	<div id="boutons">
			  				<a4j:commandLink styleClass="btValider" value="Valider" render ="tarifs" execute="popupconfirmationcloture" action="#{ParametrageControleur.cloturerTarif}"
								oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('popupconfirmationcloture')}.hide();}">
	                     	</a4j:commandLink>
						 	<a4j:commandLink styleClass="btAnnuler" value="Annuler" onclick="#{rich:component('popupconfirmationcloture')}.hide(); return false;" />
						</div>
	    			</rich:popupPanel>
				</div>
    		</h:form>
    	</div>
    </ui:define>
</ui:composition>
</body>
</html>